<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="/css/bootstrap.css">
    <style>
        * {
            list-style: none;
        }

        li {
            margin-top: 20px;
        }

        h5 {
            float: right;
            margin-left: 20px;
        }

        table {
            width: 1000px !important;
            margin: 0 auto;
        }

        .td2 {
            text-align: center;
        }

        td {
            padding: 15px !important;
        }

        .clearfix::after {
            content: '';
            display: block;
            clear: both;
        }

        h3 {
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="container">
        <% if(session.name){%>
            <div class="welcome clearfix">
                <h5>欢迎您<%=session.name%>
                </h5>
                <h5><a href="/logout">退出登录</a></h5>
                <h5><a href="/center">个人中心</a></h5>
            </div>
            <% } else{%>
                <div class="welcome clearfix">
                    <h5><a href="/login">登录</a></h5>
                    <h5><a href="/register">注册</a></h5>
                </div>

                <%}%>
                    <h3>笔记列表</h3>
                    <table class="table table-striped">
                        <caption>今日笔记数据</caption>
                        <tr>
                            <th>
                                标题
                            </th>
                            <td class="td2" colspan="2">
                                操作
                                <a href="/add" class="add">添加</a>
                            </td>
                        </tr>
                        <tr>
                            <% for(let i=0;i<data.length;i++){%>
                        <tr>
                            <td><a href="/detail/<%=data[i]._id%>">
                                    <%=data[i].Title %>
                                </a></td>
                            <td><a href="/edit?id=<%=data[i]._id%>">编辑</a></td>
                            <td><a href="/delete?id=<%=data[i]._id%>">删除</a></td>
                        </tr>
                        <% } %>
                            </tr>
                    </table>
    </div>
</body>

</html>